﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using DatabaseGroup.SSIS.SourceAdapters.View;

namespace DatabaseGroup.IntegrationTests.SSIS.SourceAdapters
{
    class MockView : IEditorGeneralView, IEditorColumnView, IEditorAdvanceView, IEditorErrorView,
        IEditorAuditView, IEditorPreviewView, IEditorMainView
    {
        private Dictionary<EditorViewTab, ITabSettings> _settings = new Dictionary<EditorViewTab, ITabSettings>();

        #region IEditorMainView Members

        public event EventHandler SavedSettings;

        public void CloseView(bool dialogResultIsOK)
        { }

        #endregion

        #region IEditorBaseView Members

        public event System.ComponentModel.CancelEventHandler SavingSettings;
        public event EventHandler CancelSettings;
        public event CancelTabEventHandler LeavingTab;
        public event TabEventHandler ViewSettings;

        public void ShowErrorMessage(string message)
        { }

        public void HideErrorMessage()
        { }

        public bool RequestUserConfirmation(string message)
        {
            return false;
        }

        public void ShowAlert(string message)
        { }

        public T GetTabSettings<T>(EditorViewTab tab) where T : ITabSettings
        {
            return (T) _settings[tab];
        }

        #endregion

        #region IEditorPreviewView Members

        public event EventHandler RefreshPreview;

        public void BindPreviewTab(PreviewTabSettings settings)
        {
            _settings[EditorViewTab.Preview] = settings;
        }

        public void PopulatePreviewRows(List<string> headers, List<string[]> rows)
        { }

        #endregion

        #region IEditorAuditView Members

        public event EventHandler LogSourceDataTypeUpdated;
        public event EventHandler ErrorSourceDataTypeUpdated;

        public void BindAuditTab(AuditTabSettings settings)
        {
            _settings[EditorViewTab.Auditing] = settings;
        }

        public void SetErrorSourceSizeAvailability(bool inputIsAvailable)
        { }

        public void SetLogSourceSizeAvailability(bool inputIsAvailable)
        { }

        #endregion

        #region IEditorErrorView Members

        public void BindErrorTab(ErrorTabSettings settings)
        {
            _settings[EditorViewTab.Error] = settings;
        }

        #endregion

        #region IEditorAdvanceView Members

        public event EventHandler AddNewAdvanceColumn;
        public event IndexEventHandler AddNewAdvanceColumnBefore;
        public event IndexEventHandler AddNewAdvanceColumnAfter;
        public event IndexEventHandler RemoveAdvanceColumn;
        public event IndexEventHandler SelectedAdvanceColumnChanged;

        public int AdvanceColumnTopIndex { get; set; }

        public void BindAdvanceTab(AdvanceTabSettings settings)
        {
            _settings[EditorViewTab.Advance] = settings;
        }

        public void ViewAdvanceColumnProperties(int columnIndex, object propertiesObject)
        { }

        #endregion

        #region IEditorColumnView Members

        public event EventHandler ResetColumns;
        public event EventHandler MainDelimitersChanged;

        public void BindColumnTab(ColumnTabSettings settings)
        {
            _settings[EditorViewTab.Columns] = settings;
        }

        public void PopulateColumnPreviewRows(List<string> headers, List<string[]> rows)
        { }

        #endregion

        #region IEditorGeneralView Members

        public event EventHandler FileConnectionChange;

        public void BindGeneralTab(GeneralTabSettings settings)
        {
            _settings[EditorViewTab.General] = settings;
        }

        public void PopulateFileConnections(List<string> connections, string selected)
        { }

        public void PopulateCodePageList(string[] items)
        { }

        public void PopulateLocaleList(string[] items)
        { }

        #endregion

        public void SaveSettings()
        {
            if (SavingSettings != null)
                SavingSettings(this, new CancelEventArgs());
        }
    }
}
